package apiTest;

import cn.com.elite.Util;
import cn.com.kh.hst.ThreeDesUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.HashMap;
import java.util.Map;

/* 4.29客户注册数据查询接口 */
public class API_Dev429 {
    private static final Log log = LogFactory.getLog(API_Dev429.class);

    public static void main(String[] args) throws Exception {

        String m_ApiURL = "https://cs-feature.mgbl.com.my/ae/query-register-info";

        String appid = "40001";
        String appsecret = "zf7HxnNBg2o8fnCf611";
        String apptoken = "bad62f2702eb44a2ab22e39dd8fd7c4b-652";
        String hsNo = "11049140";

        String sign_time = String.valueOf(System.currentTimeMillis());
        log.debug("解析信息-" + "sign_time: " + sign_time);

        HashMap<String, String> paramHashMap = new HashMap<String, String>() {
            {
                put("sign_time", sign_time);
                put("hsNo", hsNo);
                put("token", apptoken);
            }
        };

        log.debug("paramHashMap：" + paramHashMap);
        //自然排序 升序参数
        String signfront = ThreeDesUtil.sortMap(paramHashMap, appid, appsecret);
        log.debug("sign加密MD5前：" + signfront);
        String signafter = Util.getMD5Str(signfront);
        log.debug("sign加密MD5后：" + signafter);

        //拼接接口入参
        paramHashMap.put("client_key", appid);
        paramHashMap.put("sign", signafter);

        String injson = ThreeDesUtil.SplicingMap(paramHashMap, "&");
        log.debug("injson:" + injson);

        Map<String, String> headMap = new HashMap<String, String>();
        headMap.put("Content-Type", "application/x-www-form-urlencoded");
        String getResult = Util.doHttpPostUseHead(m_ApiURL, injson, "UTF-8", 10000, 0, headMap);
        log.debug("4.29客户注册数据查询接口 Result:" + getResult);

    }
}